str2= '123456789'
console.log('str2 ->', Number(str2).toLocaleString());

str = '123456789'
let arr = []
Array.from(str)
for (let i = 0; i < str.length; i++) {
    arr.push(str[i])
    if((i+1) % 3 == 0) {
        arr.push(',')
    }
}
arr.pop()
console.log(arr.join('').split(',').toString());